package com.dragon.modules.yuegou.model.system;

import com.dragon.modules.yuegou.entity.system.RoleEntity;
import com.dragon.modules.yuegou.enums.GroupRole;
import com.dragon.modules.yuegou.enums.OwnerType;
import com.dragon.modules.yuegou.enums.PlatformRole;
import com.dragon.modules.yuegou.enums.system.RoleStatus;
import com.dragon.modules.yuegou.enums.system.RoleType;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * 系统角色模型类
 * 
 * @author pbuilder generated
 * @date 2019-03-15 15:37:59
 * @company sgy
 * @version 2.0
 * @see Length 长度限制
 * @see NotNull 对象非空
 * @see NotEmpty 字符串、集合、表、数组非空
 */
public class Role extends RoleEntity {

	/**
	 * 构造一个空系统角色模型对象
	 */
	public Role(){
		super();
	}
	
	/**
	 * 依据实体对象的信息构造一个系统角色模型对象
	 * 
	 * @param entity 实体对象
	 */
	public Role(RoleEntity entity){
		super(entity);
	}

	/**
	 * 依据其它对象的信息构造一个系统角色模型对象
	 * 
	 * @param other 其它对象
	 */
	public Role(Role other){
		super(other);
	}
	
	public static Role fromPlatformRole(PlatformRole role) {
		Role model = new Role();
		model.setId(role.getId());
		model.setRoleName(role.getAlias());
		model.setEnName(role.getKey());
		model.setDescription(role.getDescription());
		model.setDel(false);
		model.setStatus(RoleStatus.ENABLED);
		model.setType(RoleType.SYSTEM);
		model.setOwnerType(OwnerType.PLATFORM);
		return model;
	}
	
	public static Role fromGroupRole(GroupRole role, String groupId) {
		Role model = new Role();
		model.setRoleName(role.getAlias());
		model.setEnName(role.getKey());
		model.setDescription(role.getDescription());
		model.setDel(false);
		model.setStatus(RoleStatus.ENABLED);
		model.setType(RoleType.SYSTEM);
		model.setOwnerType(OwnerType.GROUP);
		model.setGroupId(groupId);
		return model;
	}


	@Override
	public String getId() {
    	return id;
    }

    /**
	 * 设置
	 * 
	 * @param id 
	 * @return 当前对象
	 */
    public Role id(String id) {
    	this.id = id;
    	return this;
    }

	@Override
	public String getRoleName() {
    	return roleName;
    }

    /**
	 * 设置角色名
	 * 
	 * @param roleName 角色名
	 * @return 当前对象
	 */
    public Role roleName(String roleName) {
    	this.roleName = roleName;
    	return this;
    }

	@Override
	public String getDescription() {
    	return description;
    }

    /**
	 * 设置描述
	 * 
	 * @param description 描述
	 * @return 当前对象
	 */
    public Role description(String description) {
    	this.description = description;
    	return this;
    }

	@Override
	public String getEnName() {
    	return enName;
    }

    /**
	 * 设置英文名
	 * 
	 * @param enName 英文名
	 * @return 当前对象
	 */
    public Role enName(String enName) {
    	this.enName = enName;
    	return this;
    }

	@Override
	public RoleStatus getStatus() {
    	return status;
    }

    /**
	 * 设置[枚举]状态：1-已启用-ENABLED、2-禁用-DISABLED
	 * 
	 * @param status [枚举]状态：1-已启用-ENABLED、2-禁用-DISABLED
	 * @return 当前对象
	 */
    public Role status(RoleStatus status) {
    	this.status = status;
    	return this;
    }
    
    @Override
	public RoleType getType() {
    	return type;
    }

    /**
	 * 设置[枚举]类型：0-用户级-USER、2-系统级-SYSTEM
	 * 
	 * @param type [枚举]类型：0-用户级-USER、2-系统级-SYSTEM
	 * @return 当前对象
	 */
    public Role type(RoleType type) {
    	this.type = type;
    	return this;
    }

	@Override
	public OwnerType getOwnerType() {
    	return ownerType;
    }

    /**
	 * 设置[全局枚举]所有者类型：0-平台-PLATFORM、1-集团-GROUP、2-商圈-BUSINESS_DISTRICT、3-商户-MERCHANT
	 * 
	 * @param ownerType [全局枚举]所有者类型：0-平台-PLATFORM、1-集团-GROUP、2-商圈-BUSINESS_DISTRICT、3-商户-MERCHANT
	 * @return 当前对象
	 */
    public Role ownerType(OwnerType ownerType) {
    	this.ownerType = ownerType;
    	return this;
    }

	@Override
	public String getBusdId() {
    	return busdId;
    }

    /**
	 * 设置商圈id
	 * 
	 * @param busdId 商圈id
	 * @return 当前对象
	 */
    public Role busdId(String busdId) {
    	this.busdId = busdId;
    	return this;
    }

	@Override
	public String getGroupId() {
    	return groupId;
    }

    /**
	 * 设置集团id
	 *
	 * @param groupId 集团id
	 * @return 当前对象
	 */
    public Role groupId(String groupId) {
    	this.groupId = groupId;
    	return this;
    }

	@Override
	public LocalDateTime getCreatedTime() {
    	return createdTime;
    }

    /**
	 * 设置
	 * 
	 * @param createdTime 
	 * @return 当前对象
	 */
    public Role createdTime(LocalDateTime createdTime) {
    	this.createdTime = createdTime;
    	return this;
    }

	@Override
	public String getCreatedBy() {
    	return createdBy;
    }

    /**
	 * 设置
	 * 
	 * @param createdBy 
	 * @return 当前对象
	 */
    public Role createdBy(String createdBy) {
    	this.createdBy = createdBy;
    	return this;
    }

	@Override
	public LocalDateTime getModifiedTime() {
    	return modifiedTime;
    }

    /**
	 * 设置
	 * 
	 * @param modifiedTime 
	 * @return 当前对象
	 */
    public Role modifiedTime(LocalDateTime modifiedTime) {
    	this.modifiedTime = modifiedTime;
    	return this;
    }

	@Override
	public String getModifiedBy() {
    	return modifiedBy;
    }

    /**
	 * 设置
	 * 
	 * @param modifiedBy 
	 * @return 当前对象
	 */
    public Role modifiedBy(String modifiedBy) {
    	this.modifiedBy = modifiedBy;
    	return this;
    }

	@Override
	public Boolean getDel() {
    	return del;
    }

    /**
	 * 设置逻辑删除，1表示已删除,0表示未删除
	 * 
	 * @param del 逻辑删除，1表示已删除,0表示未删除
	 * @return 当前对象
	 */
    public Role del(Boolean del) {
    	this.del = del;
    	return this;
    }

	@Override
	public String getDelBy() {
    	return delBy;
    }

    /**
	 * 设置
	 * 
	 * @param delBy 
	 * @return 当前对象
	 */
    public Role delBy(String delBy) {
    	this.delBy = delBy;
    	return this;
    }

	@Override
	public LocalDateTime getDelTime() {
    	return delTime;
    }

    /**
	 * 设置
	 * 
	 * @param delTime 
	 * @return 当前对象
	 */
    public Role delTime(LocalDateTime delTime) {
    	this.delTime = delTime;
    	return this;
    }

}
